export const dialog = function () {
  const {title, message, buttonText, event} = arguments[0]
  const HTML = document.documentElement
  let dialog = document.createElement('div')
  dialog.setAttribute('dialog', '')
  let wrapper = `
    <div class="wrapper">
      <p class="title">${title}</p>
      <p class="message">${message}</p>
      <button id="removeDialog" opacity>${buttonText}</button>
    </div>
  `
  dialog.innerHTML = wrapper
  HTML.appendChild(dialog)
  let that = this
  document.querySelector('#removeDialog').onclick = function () {
    dialog.setAttribute('removeDialog', '')
    setTimeout(function () {
      HTML.removeChild(dialog)
    }, 300)
    event.call(that)
  }
}
